package com.fitso.model.dao.hibernate;

import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.fitso.model.context.ContextFactory;
import com.fitso.model.dao.FoodDao;
import com.fitso.model.dao.FoodJournalDao;
import com.fitso.model.dao.FoodJournalDaoDB_IT;
import com.fitso.model.dao.UserDao;

/**
 * Hibernate implementation test of {@link FoodJournalDao}
 * 
 * <strong>Test Query</strong>
 * 
 * <pre>
 * SELECT u.first_name, u.last_name, fj.at, 
 *      f.name, f.calories, f.protein, 
 *      f.total_carbs, f.sugar, f.fiber
 * FROM fitso.user u
 * JOIN fitso.food_journal fj
 * ON u.id = fj.user_id
 * JOIN fitso.food f
 * ON f.id = fj.food_id
 * </pre>
 * 
 * @author timothystorm
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:fitso-model-context.xml" })
public class HibernateFoodJournaDao_IT extends FoodJournalDaoDB_IT {
	protected String[] getDataFileNames() {
		return new String[] { "src/test/resources/datasets/food_dataset.xml",
				"src/test/resources/datasets/food_journal_dataset.xml" };
	}

	public FoodDao newFoodDao() {
		return (FoodDao) ContextFactory.getBean("HibernateFoodDao");
	}

	public FoodJournalDao newFoodJournalDao() {
		return (FoodJournalDao) ContextFactory.getBean("HibernateFoodJournalDao");
	}

	public UserDao newUserDao() {
		return (UserDao) ContextFactory.getBean("HibernateUserDao");
	}
}
